package cn.zxhysy.booksmall.service.impl;

import cn.zxhysy.booksmall.entity.Car;
import cn.zxhysy.booksmall.mapper.CarMapper;
import cn.zxhysy.booksmall.service.CarService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class CarServiceImpl implements CarService {
    private final CarMapper carMapper;

    public CarServiceImpl(CarMapper carMapper) {
        this.carMapper = carMapper;
    }

    @Override
    public List<Car> getWaitCarList(String concreteName) {
        Example carExample = new Example(Car.class);
        Example.Criteria criteria = carExample.createCriteria();
        criteria.andGreaterThan("iCOrder", 0);
        carExample.orderBy("iCOrder").asc();
        if (StringUtils.isNoneBlank(concreteName)) {
            criteria.andEqualTo("concreteName", concreteName);
        }
        return carMapper.selectByExample(carExample);
    }
}
